package cz.proks.bank.service;

import javax.jws.WebService;

@WebService(endpointInterface = "cz.proks.bank.service.ScoreService", 
			serviceName = "ScoreService",
			portName="ScoreServicePort",
			targetNamespace = "http://bank.proks.cz/service/ScoreService/" 
			)
public class ScoreServiceImpl implements ScoreService {

	@Override
	public double getClientBonity(long availableMoney, long requestedLoan, long totalLoans) {				
		
		double bonity = countBonity(requestedLoan, totalLoans, availableMoney);

		return bonity;
	}
	
	private double countBonity(long requestedLoan, long totalLoans, long disposableMoney) {
		double bonity = (requestedLoan + totalLoans) / 10 * disposableMoney;
		return bonity > 1 ? 1d : bonity;
	}

}
